<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <base href="${pageContext.request.contextPath}/"/>
    <title>襄阳蓝芯智能化办公系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        /*定义类名为.thead-blue的样式*/
        .thead-blue {
            color: #fff;
            font-weight: bold;
            background-color: #337ab7;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="view/bootstrap-3.3.5/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="view/bootstrapvalidator/css/bootstrapValidator.css"/>
    <script charset="utf-8" src="view/jquery/jquery-1.10.2.min.js"></script>
    <script charset="utf-8" src="view/bootstrap-3.3.5/js/bootstrap.js"></script>
    <script charset="utf-8" src="view/bootstrapvalidator/js/bootstrapValidator.js"></script>
</head>
<body>

<form action="apply/payeeInformal" id="myform" method="post" class="form-horizontal" role="form">
    <div class="panel panel-primary">
        <table class="table table-bordered table-hover">
            <thead>
            <tr class="thead-blue">
                <td colspan="4">报销申请领款登记</td>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td class="col-md-2"><label>申请单号</label></td>
                <td class="col-md-4">${bx.docNo}</td>
                <td class="col-md-2"><label>审批流程</label></td>
                <td class="col-md-4">${bx.lcflow.flowName}</td>
            </tr>
            <tr>
                <td><label>创建人</label></td>
                <td>${bx.empcreator.empName}</td>
                <td><label>单据类型</label></td>
                <td>
                    ${bx.docType=='BXD'?"报销申请单":"" }
                    ${bx.docType=='GMD'?"资产购买申请单":"" }
                    ${bx.docType=='YDD'?"资产移动申请单":"" }
                </td>

            </tr>
            <tr>
                <td><label>申请人</label></td>
                <td>${bx.empproposer.empName}</td>
                <td><label>申请时所在部门</label></td>
                <td>${bx.dept.deptName}</td>
            </tr>
            <tr>
                <td><label>申报金额</label></td>
                <td>${bx.applyAmount}</td>
                <td><label>实报金额</label></td>
                <td>${bx.bookAmount}</td>
            </tr>
            <tr>
                <td><label>创建时间</label></td>
                <td>${bx.createDate}</td>
                <td><label>提交时间</label></td>
                <td> ${bx.submitDate}</td>
            </tr>
            <tr>
                <td><label>领款人</label></td>
                <td>
                    <input type="hidden" id="oid" name="oid" value="${bx.oid}">
                    <input type="hidden" id="payee" name="payee" value="${bx.payee}">
                    <div class="input-group">
                        <input type="text" id="empName" name="empName"
                               readonly="readonly" class="form-control" placeholder="请选择领款人"> <span
                            class="input-group-btn">
									<button class="btn btn-info" type="button" data-toggle="modal"
                                            data-target="#selectempModal">请选择</button>
								</span>
                    </div>
                </td>
                <td><label>领款登记人</label></td>
                <td>${bx.empbooker.empName}</td>
            </tr>
            <tr>
                <td><label>领款时间</label></td>
                <td>${bx.bookDate}</td>
                <td><label>单据状态</label></td>
                <td>
                    <c:if test='${bx.status=="W" }'>
                        未提交
                    </c:if>
                    <c:if test='${bx.status=="S" }'>
                        审批中
                    </c:if>
                    <c:if test='${bx.status=="Y" }'>
                        审批通过
                    </c:if>
                    <c:if test='${bx.status=="N" }'>
                        审批不通过
                    </c:if>
                    <c:if test='${bx.status=="O" }'>
                        已领款
                    </c:if>
                </td>
            </tr>
            <tr>
                <td><label>申请事由</label></td>
                <td colspan="3">${bx.reason}</td>
            </tr>
            <tr class="thead-blue">
                <td colspan="4">报销明细</td>
            </tr>

            <c:forEach items="${bx.maldetails}" var="m">
                <tr>
                    <td><label>报销类型</label></td>
                    <td>${m.bxtype.name}
                        <input type="hidden" name="typeid" id="typeid" value="${m.typeid}">
                    </td>
                    <td><label>申报金额</label></td>
                    <td>${m.applyAmount}
                        <input type="hidden" name="applyAmount" id="applyAmount" value="${m.applyAmount}">
                    </td>
                </tr>
                <tr>
                    <td><label>实报金额</label></td>
                    <td class="form-group">
                        <div>
                            <input type="hidden" name="doid" value="${m.oid}">
                            <input type="text" id="amount" name="amount" title="${m.applyAmount}" class="form-control"
                                   placeholder="请输入实报金额">
                        </div>
                    </td>
                    <td colspan="2"></td>
                </tr>
            </c:forEach>

            <tr class="thead-blue">
                <td colspan="4">附件</td>
            </tr>

            <c:forEach items="${bx.malaccessary}" var="a">
                <tr>
                    <td><label>附件1</label></td>
                    <td>
                        <input type="hidden" name="contentfile" value="${a.content}">
                        <A href="apply/downloadBxFile?oid=${a.oid}">${a.content}</A>
                    </td>
                    <td><label>附件描述</label></td>
                    <td>${a.description}</td>
                </tr>
            </c:forEach>

            <tr>
                <td colspan="4" align="center">
                    <a type="button" href="javascript:history.back()" class="btn btn-info">返回</a>
                    <button type="submit" class="btn btn-success">提交信息</button>
                    <button type="reset" id="resetbtn" class="btn btn-default">取消操作</button>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</form>
<%@include file="../modal/selectemp.jsp" %>
<script type="text/javascript">
    function setempvalue(eid, empName) {
        $("#payee").val(eid);
        $("#empName").val(empName);
    }
</script>
</body>


<script type="text/javascript">
    $(document).ready(function () {

        $("#myform").bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {/*input状态样式图片*/
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                amount: {
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '实报金额不能为空!'
                        },
                        regexp: {
                            regexp: /^(?!(0[0-9]{0,}$))[0-9]{1,}[.]{0,}[0-9]{0,}$/,
                            message: '实报金额格式不正确,金额必须大于0!'
                        },
                        callback: {
                            message: '实报金额不能大于申报金额',
                            callback: function (value, validator, $field) {
                                if (parseFloat($field.val()) > parseFloat($field.prop("title"))) {
                                    return false;
                                }
                                return true;
                            }
                        }
                    }
                }
                // empName : {
                //     validators: {
                //         notEmpty : {/*非空提示*/
                //             message : '领款人不能为空!'
                //         }
                //     }
                // }
            },
            submitHandler: function (validator, form, submitButton) {
                validator.defaultSubmit();
            }
        });


        $("#resetbtn").click(function () {
            $("#myform").data("bootstrapValidator").resetForm();
        });


    });
</script>
</html>